<include file="public@header"/>
<style>
.table img{
	width:25px;
	height:25px;
}

#pop{
    display:none; 
}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a>{:lang('USER_INDEXADMIN_INDEX')}</a></li>
        <li><a href="{:url('adminIndex/add')}">{:lang('ADD')}</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('user/adminIndex/index')}">
    

        
        热门：
        <select class="form-control" name="ishot">
            <option value="">全部</option>
                <option value="1" <if condition="input('request.ishot') neq '' && input('request.ishot') eq 1">selected</if>>是</option>
                <option value="0" <if condition="input('request.ishot') neq '' && input('request.ishot') eq 0">selected</if>>否</option>
        </select>
        
        
        设备来源：
        <select class="form-control" name="source">
            <option value="">全部</option>
                <option value="pc" <if condition="input('request.source') neq '' && input('request.source') eq 'pc'">selected</if>>PC</option>
                <option value="android" <if condition="input('request.source') neq '' && input('request.source') eq 'android'">selected</if>>安卓APP</option>
                <option value="ios" <if condition="input('request.source') neq '' && input('request.source') eq 'ios'">selected</if>>苹果APP</option>
        </select>

        提交时间：
        <input class="form-control js-bootstrap-date" name="start_time" id="start_time" autocomplete="off" value="{:input('request.start_time')}" aria-invalid="false" style="width: 110px;"> - 
        <input class="form-control js-bootstrap-date" name="end_time" id="end_time" autocomplete='off' value="{:input('request.end_time')}" aria-invalid="false" style="width: 110px;">
            
        用户ID：
        <input class="form-control" type="text" name="uid" style="width: 200px;" value="{:input('request.uid')}"
               placeholder="请输入用户ID">
        关键字：
        <input class="form-control" type="text" name="keyword" style="width: 200px;" value="{:input('request.keyword')}"
               placeholder="用户名/昵称">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('user/adminIndex/index')}">清空</a>
        <br>
        <br>
        用户数：{$nums}  (根据条件统计)
    </form>
    <form method="post" class="js-ajax-form">

        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                    </label>
                </th>
                <th>ID</th>
                <th>{:lang('USERNAME')}</th>
                <th>{:lang('NICENAME')}</th>
                <th>{:lang('AVATAR')}</th>
                <th>手机</th>
                <th>{$name_coin}余额</th>
                <th>累计消费{$name_coin}</th>
                <th>{$name_votes}余额</th>
                <th>累计{$name_votes}</th>
                <th>注册设备</th>
                <th>{:lang('REGISTRATION_TIME')}</th>
                <th>{:lang('LAST_LOGIN_TIME')}</th>
                <th>{:lang('LAST_LOGIN_IP')}</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>

            <foreach name="list" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" value="{$vo.id}">
                    </td>
                    <td>{$vo.id}</td>

                    <td>{$vo['user_login']?$vo['user_login']:($vo['mobile']?$vo['mobile']:lang('THIRD_PARTY_USER'))}
                    </td>
                    <td>{$vo['user_nicename']?$vo['user_nicename']:lang('NOT_FILLED')}</td>
                    <td><img src="{$vo['avatar']}" class="imgtip" /></td>
                    <td>{$vo.mobile}</td>
                    <td>{$vo.coin}</td>
                    <td>{$vo.consumption}</td>
                    <td>{$vo.votes}</td>
                    <td>{$vo.votestotal}</td>

                    <td>{$vo.source}</td>

                    <td>{:date('Y-m-d H:i:s',$vo['create_time'])}</td>
                    <td><if condition="$vo['last_login_time'] gt 0">{:date('Y-m-d H:i:s',$vo['last_login_time'])}<else />--</if></td>
                    <td>{$vo.last_login_ip}</td>

                    <td>
     

               
						<if condition="$vo.ishot eq '1'">
							<a class="btn btn-xs btn-info js-ajax-dialog-btn"
								   href="{:url('adminIndex/sethot',array('id'=>$vo['id'],'ishot'=>0))}">取消热门</a>
						<else/>
							<a class="btn btn-xs btn-info js-ajax-dialog-btn"
								   href="{:url('adminIndex/sethot',array('id'=>$vo['id'],'ishot'=>1))}">热门</a>
						</if>
						
     
                        <a class="btn btn-xs btn-primary" href='{:url("adminIndex/edit",array("id"=>$vo["id"]))}'>{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('adminIndex/del',array('id'=>$vo['id']))}">{:lang('DELETE')}</a>
                        
                    </td>
                </tr>
            </foreach>
            </tbody>
        </table>
        <div class="pagination">{$page}</div>
    </form>
</div>

<div id="pop">
    <div class="wrap" style="padding-bottom:40px;">
        <form method="post" class="form-horizontal margin-top-20">
            <div class="form-group">
                <label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>禁用截止日期</label>
                <div class="col-md-6 col-sm-10">
                    <input class="form-control js-bootstrap-date" name="ban_long" contenteditable="off" id="ban_long" value="" aria-invalid="false">
                </div>
            </div>
            
            <div class="form-group">
                <label for="input-user_login" class="col-sm-2 control-label"><span class="form-required">*</span>禁用原因</label>
                <div class="col-md-6 col-sm-10">
                    <textarea class="form-control" id="ban_reason" name="ban_reason" placeholder="200字以内"></textarea> 
                </div>
            </div>
            
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <a href="javascript:void(0)" class="btn btn-primary" onclick="xiajia_submit()">禁用</a>
                </div>
            </div>
        </form>
    </div>
</div>
            
<script src="__STATIC__/js/admin.js"></script>
<script src="__STATIC__/js/laydate/laydate.js"></script>
<script>
        Wind.use('layer');
		var clickuid='0';
		function showlayer(id){
			clickuid=id;
            layer.open({
                type: 1,
                title: '禁用',
                shadeClose: true,
                shade: 0.8,
                area: ['800px', '300px'],
                content: $('#pop'),
                success:function(){
                    laydate.render({
                        elem: '#ban_long',//指定元素
                        trigger: 'click'
                    });
                }
            }); 
		}
	
		
		var xiajia_status=0;
		function xiajia_submit(){
			var ban_long=$("#ban_long").val();
			var reason=$("#ban_reason").val();

            if(ban_long==''){
                layer.msg("请选择禁用截止日期");
                return;
            }

            if(reason==''){
                layer.msg("请填写禁用原因");
                return;
            }

            if(reason.length>200){
                layer.msg("禁用原因必须在200字以内");
                return;
            }

			if(xiajia_status==1){
				return;
			}
			xiajia_status=1;
			$.ajax({
				url: '{:url('user/adminIndex/setBan')}',
				type: 'POST',
				dataType: 'json',
				data: {id:clickuid,reason: reason,ban_long:ban_long},
				success:function(data){
					var code=data.code;
					if(code==0){
						layer.msg(data.msg);
						return !1;
					}

					xiajia_status=0;
					
					layer.msg("操作成功",{},function(){
						//layer.closeAll();
                        clickuid=0;
						$("#ban_long").val("");
						$("#ban_reason").attr("value","");
						layer.closeAll();
                        reloadPage(window);
					});
				},
				error:function(e){
				}
			});
			
		}
</script>
</body>
</html>